Skip to main content

All Questions

-1votes
2answers
51views

how to prevent this list from being updated? [duplicate]

my program: num_cards=8 list1=[1,2,3,4,5,6,7,8] shuffle_cards=list1 for j in range(0,num_cards//2): shuffle_cards.insert((2*j)+1,shuffle_cards[(num_cards//2)+(2*j)]) shuffle_cards=shuffle_cards[0:...
Anirudh SV's user avatar
1vote
0answers
95views

Python Iterating over Numpy Tile and for-loops

Goal: Here is a sample of a dataset that has "ID", "PHASENAME", "CDAYS", "MULTI_FACTOR", "DAY_COUNTER", and "DAILY_LABOR_PERCENT". I was ...
Ty Kendall's user avatar
0votes
1answer
59views

How can i optimize or reduce for loop for this nested python dictionary? [duplicate]

I have this nested dictionary in python flag_dict = { 'modl1': { 'slide1': { 'screens': { 'screen1': { 'mp4_1': 1, '...
Nava's user avatar
1vote
0answers
29views

An index error occurs while testing parameters in my cost function

Here is the error: IndexError: index 6 is out of bounds for axis 0 with size 6 I have not done anything since I don't know how to fix the problem. My cost function gets an expected output using ...
Lori Wojciechowicz's user avatar
-2votes
2answers
97views

Is there a difference in the order of conditions in a python if statement?

Let's take the Leetcode problem, "first letter to appear twice" (https://leetcode.com/problems/first-letter-to-appear-twice/). The general solution that I came up with was to iterate over ...
poppycoder's user avatar
-1votes
2answers
112views

Python coding question regarding "stacking arrays to an array" [closed]

I have a simple Python coding question regarding "stacking array inside array". Here, I have several arrays as follows: a1 = np.array([[1,1,1],[1,1,1],[1,1,1]]) a2 = np.array([[2,2,2],[2,2,...
Eric Hwang's user avatar
1vote
3answers
33views

How to deal with bulk of array in one list?

I need a list of the results, but the out put data is array, I guess that's why the list are all inclued "array". I need to plot the list into graph, since the format looks strange, I can ...
sanshui Chen's user avatar
0votes
2answers
89views

Python loop doesn't work with readlines()

It suppose to count amount of "-------------------------" lines but it doesn't work, also line with print("test") doesn't shows in console and it always returns 0. But for example ...
vokeme's user avatar
0votes
1answer
64views

How to change title in for loop with different nc files?

I have 49 .nc files that I want to plot (map). These nc files are from a atmospheric simulation. the variable I am interested in is "foot" or footprints, with lon, lat, time (73 times). I ...
Nafb's user avatar
-1votes
4answers
198views

Difference between C array and python array [duplicate]

a=input("type sentence: ") for i in range(1, 100): if a[i] == 'a': print (a[i]) elif a[i] == 'o': break According to my experience, in C, we can use a[i] with for ...
Love_to_sleep's user avatar
0votes
5answers
223views

How to print differences between 2 elements of an array in a form of another array

As an example I have an array of 5 elements: Input array: ele = [2, 5, 9, 1, 4] I want to output an array that has difference between all the elements but not repeated difference (ie, I don't want to ...
newprogrammer's user avatar
0votes
2answers
446views

I am trying to find a way to act on characters in an array in Python

I am very new to coding and Python. I am trying to change characters in string elements of an array conditional on their adjacency to another character. These characters are grouped into arrays based ...
Usergyt's user avatar
0votes
1answer
132views

Append elements to different lists based on if-else statements in python

I have been trying to create the following program in Python. However, I am getting frustrated with my program, and I have no idea what I should be doing! Specifically, I am having trouble appending ...
Selah's user avatar
1vote
1answer
54views

indexing a numpy array by an array of indices in a loop

i have a vector i want to shuffle in batches. the idea i came up with is to reshape it into 2D array with each row as a batch. then i shuffle each row on its own. this is toy example of the approach # ...
Eric Johnson's user avatar
-1votes
2answers
54views

Python String Comparisons, why does x for x not work with list of lists

I am trying to get a value out of a list of array of strings based on another value in the same array. zone = [x for x in zoneList if (x[2] == usageRow[2])][1] This is not part of the code, just a ...
Donald Deutscher's user avatar

153050per page
close